﻿// code03060001.cpp : 多维数组
// 指针和多维数组
#include <iostream>
using namespace std;
int main()
{
    int ia[3][4]={0,1,2,3,4,5,6,7,8,9,10,11};
    int(*p)[4] = ia;//定义指向由4个整数组成的数组的指针p,
    p = &ia[2];//指针p指向ia的{8,9,10,11}

    //输出ia每个元素的值，每个内层数组各占一行
    //方法一：
    for (auto p = ia; p !=ia+3; ++p) //p指向含有4个整数的数组
    {
	    for (auto q = *p; q!=*p+4; ++q)  //q指向当前数组的首元素
	    {
            cout << *q << "\t";
	    }
        cout << endl;
    }
    //方法二：
    for (auto p=begin(ia);p!=end(ia) ; ++p)
    {
	    for (auto q=begin(*p);q!=end(*p);++q)
	    {
            cout << *q << "\t";
	    }
        cout << endl;
    }
    //方法三：本质上和方法一一样
    using int_array = int[4];
    for (int_array *p = ia; p!=ia+3; ++p)
    {
        for (int* q = *p; q != *p + 4; ++q)  
        {
            cout << *q << "\t";
        }
        cout << endl;
    }


    return 0;
}

